<script setup lang="ts">
import { ref, reactive } from 'vue'
import { CirclePlus } from '@element-plus/icons-vue'
import TitleBar from '@/components/common/TitleBar.vue'

const taskList = reactive([
  {
    id: 1,
    status: '已上线',
    title: '点奶茶',
    time: '2020-01-01 13:32:21',
  },
  {
    id: 2,
    status: '草稿',
    title: '打印机维修',
    time: '2020-01-01 13:32:21',
  },
  {
    id: 3,
    status: '已提交',
    title: '电影推荐',
    time: '2020-01-01 13:32:21',
  },
  {
    id: 4,
    status: '已提交',
    title: '买口罩',
    time: '2020-01-01 13:32:21',
  },
])
</script>

<template>
  <div class="container">
    <title-bar>自定义任务</title-bar>
    <div class="main">
      <div class="card" v-for="(item, index) in taskList" :key="item.id">
        <el-card style="max-width: 250px; height: 170px">
          <template #header>
            <div class="card-header">
              <span class="status">{{ item.status }}</span>
              <div>
                <el-button type="primary" link>编辑</el-button>
                <el-button type="primary" link>删除</el-button>
              </div>
            </div>
          </template>
          <template #default>
            <div class="card-body">
              <p class="task">{{ item.title }}</p>
              <p class="time">{{ item.time }}</p>
            </div>
          </template>
        </el-card>
      </div>

      <div class="card">
        <el-card
          style="
            max-width: 250px;
            height: 170px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
          "
        >
          <template #default>
            <div class="new-task">
              <div>
                <el-icon :size="24"><CirclePlus /></el-icon>
              </div>
              <div>新建任务</div>
            </div>
          </template>
        </el-card>
      </div>
    </div>
  </div>
</template>

<style scoped>
.container {
  width: 100%;
  background-color: #fff;
}

.main {
  padding: 40px 80px;
  display: grid;
  row-gap: 20px;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.card-header {
  display: flex;
  justify-content: space-between;
}

.card-header .status {
  font-size: 1.1rem;
  font-weight: 900;
}

.card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.card-body .task {
  font-size: 1.3rem;
  font-weight: 500;
}

.card-body .time {
  font-size: 0.7rem;
  color: #666;
}

.new-task {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
}
</style>
